<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="author" content="逯灿灿">
    <title>下拉菜单</title>
    <style>
    *{
            box-sizing: border-box;
    }
    body{
        margin: 0;
    }
    .container{
        width: 800px;
        margin: 100px auto;
    }
    .nav{
        width: 800px;
        height: 50px;
        background-color: #333;
    }
    ul{
        list-style: none;
        margin: 0;
        padding: 0 ;
    }
    .nav>ul{
        display: flex;
        line-height: 50px;
        width: 800px;
    } 
    .nav-list>li{ 
        width: 100px;
        text-align: center;
        margin: 0 40px; 
        color: white;
        position: relative;
    }
    
    .nav-list>li>a{
        font-size: 16px;
        color: white;
        text-decoration: none; 
    }
    .message{
        position: absolute;
    }
    .message{
        margin: 0;
        width: 100px;
        left: 0px;
        top: 50px;
        border: 1px solid black;
        position: absolute; 
        display: none;
        background-color:white; 
    }
    .message li{
       text-align: center;
    }
    .message li a{
        text-decoration: none;
        color: gray;
    }
    </style>
</head>

<body>
    <div class="container">
        <nav class="nav">
            <ul class="nav-list">
                <li><a href="#">公司简介</a>
                    <ul class="message">
                        <li><a href="">内容1</a></li>
                        <li><a href="">内容2</a></li>
                        <li><a href="">内容3</a></li>
                        <li><a href="">内容4</a></li>
                    </ul>
                </li>
                <li><a href="#">产品介绍</a>
                    <ul class="message">
                        <li><a href="">内容1</a></li>
                        <li><a href="">内容2</a></li>
                        <li><a href="">内容3</a></li>
                        <li><a href="">内容4</a></li>
                    </ul>
                </li>
                <li><a href="#">联系我们</a>
                    <ul class="message">
                        <li><a href="">内容1</a></li>
                        <li><a href="">内容2</a></li>
                        <li><a href="">内容3</a></li>
                        <li><a href="">内容4</a></li>
                    </ul>
                </li>
                <li><a href="#">人才招聘</a>
                    <ul class="message">
                        <li><a href="">内容1</a></li>
                        <li><a href="">内容2</a></li>
                        <li><a href="">内容3</a></li>
                        <li><a href="">内容4</a></li>
                    </ul>
                </li>
            </ul>
        </nav>
    </div>
    <script src="./js/jquery.js"></script>
</body>

</html>
<script>
    
    var list = $('.nav-list').children('li');
    var lista = $('.nav-list>li').children('a');
    var mess = $('.message');
    var messa = $('.message>li').children('a');
    var index = 0;
    list.hover(function(){
        var count = list.index(this);  
        lista.eq(count).css('color','red').css('text-decoration','underline');
        mess.eq(count).css('display','block');
        messa.hover(function(){
            $(this).css('text-decoration','underline');
            lista.css('color','white').css('text-decoration','none');
        },function(){
            $(this).css('text-decoration','none');
        })
    },function(){
         mess.css('display','none');
         lista.css('color','white').css('text-decoration','none');
    });

</script>